package com.cj.interceptor;

import net.sf.cglib.proxy.MethodInterceptor;
import net.sf.cglib.proxy.MethodProxy;

import java.lang.reflect.Method;

/**
 * @author caojie
 * @version 1.0
 * @Description
 * @date 2023/7/25 16:53
 */
public class CglibProxyInterceptor2 implements MethodInterceptor {
    public Object intercept(Object o, Method method, Object[] objects, MethodProxy methodProxy) throws Throwable {
        if("test1".equals( method.getName())){
            System.out.println("实现接口逻辑");
            return "接口返回";
        }else{
            System.out.println("before");
            Object invoke = methodProxy.invokeSuper(o, objects);
            System.out.println("after");
            return invoke;
        }
    }
}
